package com.huatai.exchange.impl;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.dal.dao.ExcExchangeDateFileDAO;
import com.huatai.exchange.dal.model.ExcExchangeDateFile;
import com.huatai.exchange.service.ExcExchangeDateFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExcExchangeDateFileServiceImpl implements ExcExchangeDateFileService {

    @Autowired
    private ExcExchangeDateFileDAO excExchangeDateFileDAO ;

    @Override
    public List<ExcExchangeDateFile> queryExcExchangeDateFileList(ExcExchangeDateFile excExchangeDateFile) throws BusinessException {
        List<ExcExchangeDateFile> excExchangeDateFiles = null;
        try{
            excExchangeDateFiles = excExchangeDateFileDAO.queryByModel(excExchangeDateFile) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return excExchangeDateFiles;
    }

    @Override
    public List<ExcExchangeDateFile> queryExcExchangeDateFileList(String exchangeInfoId) throws BusinessException {
        ExcExchangeDateFile param = new ExcExchangeDateFile();
        param.setExchangeInfoId(exchangeInfoId);
        return queryExcExchangeDateFileList(param) ;
    }

    @Override
    public void addExcExchangeDateFile(ExcExchangeDateFile excExchangeDateFile) throws BusinessException {
        try{
            excExchangeDateFileDAO.insert(excExchangeDateFile) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void deleteExcExchangeDateFile(String id) throws BusinessException {
        try{
            Long num = excExchangeDateFileDAO.deleteById(id) ;
            if(num == 0) {
                throw new BusinessException("删除失败") ;
            }
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }
}
